-
Notifications
You must be signed in to change notification settings - Fork 3.2k
chore: FIT-671: Add state transitions to the current application flows #8534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
Author
|
/fm sync |
Contributor
Author
|
/fm sync |
bmartel
commented
Nov 4, 2025
bmartel
commented
Nov 4, 2025
Co-authored-by: hlomzik <[email protected]>
Co-authored-by: robot-ci-heartex <[email protected]> Co-authored-by: hlomzik <[email protected]> Co-authored-by: nick-skriabin <[email protected]>
Removed signals usage for FSM based on Jo's suggestion.
hakan458
reviewed
Nov 4, 2025
makseq
requested changes
Nov 5, 2025
makseq
previously requested changes
Nov 5, 2025
mcanu
approved these changes
Nov 5, 2025
Contributor
Author
|
/git merge develop
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces significant improvements to the context management and finite state machine (FSM) infrastructure in the codebase, with a focus on making context propagation more robust for asynchronous jobs, enhancing FSM reliability and configurability, and introducing new state choices for annotation drafts. The most notable changes include the addition of a
CurrentContextclass for thread-local context management, improved context capture for async jobs, a more flexible state transition registration decorator, and optimizations for FSM state transitions and cache handling.Context Management and Async Job Improvements:
CurrentContextclass incore/current_request.pyto provide a unified, thread-local context management interface, including methods to set/get user, organization, and request, as well as utilities for FSM feature toggling and context clearing. All context access is now routed through this class, replacing direct thread-local usage.core/redis.pyto automatically capture and serialize relevant context (user, organization, custom job data) and inject it into job metadata, ensuring context is preserved for background tasks. [1] [2]FSM Infrastructure Enhancements:
transition_statemethod infsm/state_manager.pywith optimistic concurrency control using cache-based locks, prevention of redundant same-state transitions, and correct mapping of entity fields for state model records. Organization context is now consistently set and logged. [1] [2] [3] [4]FSM State and Transition Registration:
register_state_transitiondecorator to support trigger metadata for transitions, allowing fine-grained control over when transitions are triggered (on create, update, or specific fields).AnnotationDraftStateChoicesenum for draft annotation lifecycle states, supporting a more granular and independent workflow for annotation drafts.Other Notable Improvements:
These changes collectively improve the reliability, observability, and flexibility of both context propagation and FSM-driven workflows across the application.
Most Important Changes:
Context Management & Async Job Context Propagation:
CurrentContextfor unified thread-local context management, replacing direct_thread_localsusage and providing methods for user, organization, and request handling.FSM Infrastructure & Transition Handling:
register_state_transitiondecorator to support triggers on create, update, or specific fields, enabling more flexible FSM workflows.FSM State Choices:
AnnotationDraftStateChoicesto support a full draft annotation lifecycle, independent from main annotation states.Annotation Deletion: